const delayCallback =
  typeof requestAnimationFrame !== 'undefined'
    ? requestAnimationFrame // Browsers
    : setImmediate // Node.js

/** @doc {heading: 'Performance', subheading: 'Timing'} */
function nextFrame(): Promise<void> {
  return new Promise<void>(resolve => delayCallback(() => resolve()))
}

export { nextFrame }
